package item.inkcloud.jwtservice.service;


import io.jsonwebtoken.Claims;
import item.inkcloud.jwtservice.utils.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class JwtService {

    @Autowired
    JwtUtils jwtUtils;

    public String getToken(String userid){

        String token = jwtUtils.getToken(userid);

        return token;


    }


    public int checkToken(String token , String userid){
        System.out.println(token );

        Claims claims = jwtUtils.getClaimByToken(token);
        if (claims == null){
            System.out.println("值空");
            return 0;
        }else {
            if (claims.get("userid").equals(userid)){
                return 1;
            }else {
                System.out.println("id对不上");
                return 0;
            }

        }

    }

}
